<template>
	<view class="page-body" >
		
		<view class="list-cell b-b " @click="app.goPage('/pagesUser/pages/user_profile/user_profile?from='+from)" hover-class="cell-hover"
			:hover-stay-time="50">
			<view class="smll">
				<u-icon name="/static/img/Home/icon11-18.png" class="mr20" size="48"></u-icon>
				<text class="cell-tit">个人资料</text>
			</view>
			<view class="cell-more">编缉<u-icon name="arrow-right ml20" :size="20"></u-icon>
			</view>
		</view>
		<view class="list-cell b-b " @click="app.goPage('/pagesUser/pages/user/accountSwitch')" hover-class="cell-hover"
			:hover-stay-time="50" v-if="false">
			<view class="smll">
				<u-icon name="/static/img/Home/icon11-22.png" class="mr20" size="48"></u-icon>
				<text class="cell-tit">切换登录</text>
			</view>
			<view class="cell-more">{{ mobile.replace(code2,"$1****$2") }}<u-icon name="arrow-right ml20" :size="20"></u-icon>
			</view>
		</view>
		
		<!-- <view class="list-cell" @click="app.goPage('checkIdCard?from='+from)" hover-class="cell-hover" :hover-stay-time="50">
			<view class="smll">
				<u-icon name="/static/public/images/personal_icon_id.png" class="mr20" size="48"></u-icon>
				<text class="cell-tit">实名认证</text>
			</view>
			<view class="cell-more" v-if="userInfo.check_id_card == 0">未认证<u-icon name="arrow-right ml20" :size="20"></u-icon>
			</view>
			<view class="cell-more" v-if="userInfo.check_id_card == 1">已认证<u-icon name="arrow-right ml20":size="20"></u-icon>
			</view>
			<view class="cell-more" v-if="userInfo.check_id_card == 2">审核中<u-icon name="arrow-right ml20" :size="20"></u-icon>
			</view>
			<view class="cell-more red" v-if="userInfo.check_id_card == 3">认证失败<u-icon name="arrow-right ml20" :size="20"></u-icon>
			</view>
		</view> -->
		<!-- /pagesUser/pages/pay_pwd/pay_pwd?type=5 -->
		<view class="list-cell" @click="app.goPage('/pagesUser/pages/pay_pwd/pay_pwd?type=5')" hover-class="cell-hover" :hover-stay-time="50">
			<view class="smll">
				<u-icon name="/static/img/Home/icon11-17.png" class="mr20" size="48"></u-icon>
				<text class="cell-tit">手机号号码</text>
			</view>
			<view class="cell-more">去更改<u-icon name="arrow-right ml20" :size="20"></u-icon>
			</view>
		</view>
		<view class="list-cell" @click="app.goPage('/pagesUser/pages/user/accountSecurity?from='+from)" hover-class="cell-hover" :hover-stay-time="50">
			<view class="smll">
				<u-icon name="/static/img/Home/icon11-21.png" class="mr20" size="48"></u-icon>
				<text class="cell-tit">账号安全</text>
			</view>
			<view class="cell-more"><u-icon name="arrow-right ml20" :size="20"></u-icon>
			</view>
		</view>
		<!-- <view class="list-cell" @click="clearCache" hover-class="cell-hover" :hover-stay-time="50">
			<view class="smll">
				<u-icon name="/static/img/Home/lj.png" class="mr20" size="48"></u-icon>
				<text class="cell-tit">清除缓存</text>
			</view>
			<view class="cell-more">{{ storageSize }}<u-icon name="arrow-right ml20" :size="20"></u-icon>
			</view>
		</view> -->
		<view class="mt20" >
			<view class="list-cell b-b" @click="app.goPage('editReceivePay?from='+from)" hover-class="cell-hover"
				:hover-stay-time="50" v-if="false">
				<view class="smll">
					<u-icon name="/static/img/Home/icon11-19.png" class="mr20" size="48"></u-icon>
					<text class="cell-tit">收款信息</text>
				</view>
				<view class="cell-more">
					<u-icon name="arrow-right" :size="20"></u-icon>
				</view>
			</view>
			<view class="list-cell b-b" @click="app.goPage('/pagesUser/pages/address/address')"
				hover-class="cell-hover" :hover-stay-time="50">
				<view class="smll">
					<u-icon name="/static/img/Home/icon11-20.png" class="mr20" size="48"></u-icon>
					<text class="cell-tit">地址管理</text>
				</view>
				<view class="cell-more">
					<u-icon name="arrow-right" :size="20"></u-icon>
				</view>
			</view>
		</view>
		<!-- <view class="p20 mt40">
			<button size="default" shape="circle" type="warning" class="fs32 primarybtn"  style="background-color: #FF8200 !important;" @click="toLogout">退出登录</button>
		</view> -->
	</view>
</template>

<script>
	import { apiUserCentre } from '@/api/user';
import request from '@/utils/request'
	export default {
		data() {
			return {
				from: '',
				// userInfo: {},
				show: false,
				content: '是否清除软件缓存',
				timeot: '',
				storageSize: '',
				oop:{},
				code2:/(\d{3})\d{4}(\d{4})/,
				mobile:""
			};
		},
		onLoad(options) {
			console.log(options);
			this.oop = options;
			this.getUserInfo();
			this.from = options.from;
			this.getStorageSize()
		},
		computed: {},
		onReady() {},
		methods: {
			// 获取最新的缓存
			getStorageSize: function() {
				let that = this;
				uni.getStorageInfo({
					success(res) {
						//console.log(res.keys);
						//console.log(res.limitSize);
						let size = res.currentSize;
						if (size < 1024) {
							that.storageSize = size + ' B';
						} else if (size / 1024 >= 1 && size / 1024 / 1024 < 1) {
							that.storageSize = Math.floor(size / 1024 * 100) / 100 + ' KB';
						} else if (size / 1024 / 1024 >= 1) {
							that.storageSize = Math.floor(size / 1024 / 1024 * 100) / 100 + ' M';
						}
					}
				})
			},
			// 清除缓存
			clearCache() {
				let that = this;
				uni.showModal({
					title: '提示',
					content: '确定清除缓存吗?',
					confirmText: '立即清除',
					success(res) {
						if (res.confirm) {
							uni.clearStorageSync();
							//重新获取并显示清除后的缓存大小
							that.getStorageSize();
							uni.showToast({
								title: '清除成功',
								icon: 'none'
							})
							//清除完后跳到登录页面
							setTimeout(() => {
								uni.redirectTo({
									url: "/pages/member/center/index",
									animationType: 'pop-in',
									animationDuration: 200
								})
							}, 1300)
						}
					}
				})
			},
			getUserInfo() {
				apiUserCentre().then(res=>{
					console.log(res);
				})
				//获取登录会员信息
				// this.$u.api.getUserInfo().then(res => {
				// 	console.log(res,'--------');
				// 	this.userInfo = res.data;
				// 	this.mobile = res.data.mobile
				// 	//获取本地缓存的账号
				// 	let syncUserInfo = uni.getStorageSync('user_account');
				// 	if (syncUserInfo == '') {
				// 		syncUserInfo = [];
				// 	}
				// 	for (let i = 0; i < syncUserInfo.length; i++) {
				// 		if (syncUserInfo[i].mobile == this.userInfo.mobile) {
				// 			syncUserInfo.splice(i, 1);
				// 		}
				// 	}
				// 	syncUserInfo.unshift({
				// 		token: this.app.getAuthCode(),
				// 		mobile: this.userInfo.mobile,
				// 		nick_name: this.userInfo.nick_name,
				// 		avatar: this.userInfo.headimgurl
				// 	});
				// 	uni.setStorageSync('user_account', syncUserInfo);
				// });
			},
			//退出登录
			toLogout() {
				uni.showModal({
					content: '确定要退出登录么?',
					success: (e) => {
						if (e.confirm) {
							this.app.delAuthCode(); //清除本地登陆缓存
							this.$u.post('member/api.passport/logout').then(res => {});
							let url = '/pages/shop/index/index';
							uni.switchTab({
								url: url
							});
						}
					}
				});
			},
		}
	}
</script>

<style lang='scss' scoped>
	.list-cell {
		justify-content: space-between;
	}

	.cell-tit {
		font-size: 28rpx;
	}

	.cell-more {
		font-size: 28rpx;
		color: #5bc576;
	}
</style>

<style lang='scss' scoped>
	.smll{
		display: flex;
	}
	.list-cell{
			display:flex;
			padding: 20rpx $page-row-spacing;
			line-height:60rpx;
			position:relative;
			background: #fff;
			justify-content: space-between;
			&.log-out-btn{
				margin-top: 40rpx;
				.cell-tit{
					color: $uni-color-primary;
					text-align: center;
					margin-right: 0;
				}
			}
			&.cell-hover{
				background:#fafafa;
			}
			
			.cell-more{
				align-self: baseline;
				font-size:$font-sm;
				color:$font-color-light;
				margin-left:10rpx;
			}
			.cell-tit{
				flex: 1;
				font-size: $font-base + 2rpx;
				color: $font-color-dark;
				margin-right:10rpx;
			}
			.cell-tip{
				font-size: $font-base;
				color: $font-color-light;
			}
			
	}
</style>